package simtester.cloud;

import static org.junit.Assert.*;
import org.junit.Test

class UtilsTests {

    @Test
    void waitUntilLimit() {
        try {
            Utils.waitFor(limit: 60, step: 1) {
                
            }
            fail 'Should throw TimeoutException'
        } catch (TimeoutException e) { }
    }
    
    @Test
    void stopWaitingBeforeLimit() {
        def count = -1
        def elapsed = Utils.waitFor(limit: 60, step: 1) {
            count++
            count == 3
        }
        
        assert count == 3
        assert elapsed == 3
    }
}
